package com.bootx.officialAccount.util;

import com.bootx.officialAccount.entity.AccessToken;
import com.bootx.util.JsonUtils;
import com.bootx.util.WebUtils;
import com.fasterxml.jackson.core.type.TypeReference;

import java.util.HashMap;
import java.util.Map;

/**
 * @author black
 */
public class OfficialAccountUtils {

    private static final String APPID = "wx51e92bcdcb5fc4d7";

    private static final String APPSECRET = "498603f7c6b1985058272c2a68dc98f2";


    public static AccessToken getToken(){
        String url = "https://api.weixin.qq.com/cgi-bin/token";
        Map<String,Object> params = new HashMap<>();
        params.put("grant_type","client_credential");
        params.put("appid",APPID);
        params.put("secret",APPSECRET);
        String s = WebUtils.get(url, params);
        System.out.println(s);
        return JsonUtils.toObject(s, new TypeReference<AccessToken>() {
        });
    }





    public static void main(String[] args) {
        AccessToken token = getToken();
    }

}
